CalcDeltaArea <- function(curve1,curve2) {
  
  # This function calculated the difference in area between the input curves.
  # Specifically, the mode determines how the difference is calculated:
  #   0 - Calculate all methods
  #   1 - First less than the second
  #   2 - Vice Versa
  #   3 - Absolute difference
  #
  #====================================================================================
  
  lc1 = length(curve1)
  lc2 = length(curve2)
  if (lc1 != lc2) { error("The input curves have to be the same!") }
  
  A1 = sum(curve1)
  A2 = sum(curve2)
  
  ADelta = sum(abs(curve1 - curve2))
  
  A1Pcnt = ADelta/A1
  A2Pcnt = ADelta/A2
  
  Areas = list("A1"=A1,"A2"=A2,"ADelta"=ADelta,"A1Pcnt"=A1Pcnt,"A2Pcnt"=A2Pcnt)
  return(Areas)
}